package com.gamex.findit.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gamex.findit.dao.GameItemMapper;
import com.gamex.findit.model.GameItem;
import com.gamex.findit.service.GameItemService;

/**
 * 아이템 서비스
 * @author james
 *
 */
@Service
public class GameItemServiceImpl implements GameItemService{
	
	private static final Logger logger = LoggerFactory.getLogger(GameItemServiceImpl.class);

	@Autowired GameItemMapper gameItemMapper;
	
	@Override
	public List<GameItem> getGameItem(GameItem gameItem) throws Exception{
		List<GameItem> result = null;
		try {
			result = gameItemMapper.selectGameItem(gameItem);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public int getGameItemCount(GameItem gameItem) throws Exception{
		int count = 0;
		try {
			count = gameItemMapper.selectGameItemCount(gameItem);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return count;
	}

	@Override
	public GameItem getGameItemView(int itemNo) throws Exception{
		GameItem result = null;
		try {
			result = gameItemMapper.selectGameItemView(itemNo);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public void insertGameItem(GameItem gameItem) throws Exception{
		try {
			gameItemMapper.insertGameItem(gameItem);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

	@Override
	public void updateGameItem(GameItem gameItem) throws Exception{
		try {
			gameItemMapper.updateGameItem(gameItem);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		
	}

	@Override
	public void deleteGameItem(int itemNo) throws Exception{
		try {
			gameItemMapper.deleteGameItem(itemNo);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		
	}

	@Override
	public List<GameItem> getGameItemNo() throws Exception{
		List<GameItem> result = null;
		try {
			result = gameItemMapper.selectGameItemNo();
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

}
